package com.ml.test;

import org.objectweb.asm.*;  

/** 
 * Created by yunshen.ljy on 2015/6/8. 
 */  
public class ClassPrintVisitor extends ClassVisitor {  
   
   
    public ClassPrintVisitor() {  
        super(Opcodes.ASM4);  
    }  
   
    public void visit(int version, int access, String name,  
                      String signature, String superName, String[] interfaces) {  
        System.out.println(name + " extends " + superName + " {");  
        if(interfaces!=null){
        	for (int i = 0; i < interfaces.length; i++) {
				System.err.println(interfaces[i]);
			}
        }

    }  
   
    public FieldVisitor visitField(int access, String name, String desc,  
                                   String signature, Object value) {  
        if (name.startsWith("is")) {  
            System.out.println(" field name: " + name +"--"+ desc);  
        }  
        return null;  
    }  
   
    public MethodVisitor visitMethod(int access, String name,  
                                     String desc, String signature, String[] exceptions) {  
        if (name.startsWith("is")) {  
            System.out.println(" start with is method: " + name + desc);  
        }  
        return null;  
    }  
   
    public void visitEnd() {  
        System.out.println("}");  
    }  
}  